Date
2022-01-03 181.259933
2022-01-04 178.959442
2022-01-05 174.199158
2022-01-06 171.291183
2022-01-07 171.460495
Name: Adj Close, dtype: float64
MGMT 638
Jones Graduate School of Business
Rice University
Fall 2022
Kerry Back
Yahoo’s adjusted close is split and dividend adjusted.
!pip install pandas-datareader
from pandas_datareader import DataReader as pdr
aapl = pdr('aapl', 'yahoo', start=2010)
aapl = aapl['Adj Close']
aapl.head()Date
2022-01-03 181.259933
2022-01-04 178.959442
2022-01-05 174.199158
2022-01-06 171.291183
2022-01-07 171.460495
Name: Adj Close, dtype: float64
fret = aapl.pct_change(-1) ## AAPL and its moving average
down = (aapl.shift()>ma50.shift()) & (aapl<ma50)
up = (aapl.shift()<ma50.shift()) & (aapl>ma50)
other = (!down) & (!up)mean following down is nan%
mean following up is 0.82%
other mean is 1.18%